<template>
  <div class="dashboard-container">
    <!-- <input v-focus="'helloworld'" type="text">
    <input v-focus="'你好文件选择框'" type="file"> -->
    <el-button @click="hAdd">点我之后就可以看 test 了</el-button>
    <div class="dashboard-text">name: {{ name }}</div>
    <!-- <UploadImg /> -->
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import Layout from '@/layout'

export default {
  name: 'Dashboard',
  computed: {
    ...mapGetters(['name'])
  },
  methods: {
    hAdd() {
      // 需求: 点击按钮后才可以访问 test 页面
      // {
      //   path: '/test',
      //   component: Layout,
      //   children: [
      //     {
      //       path: '',
      //       name: 'test',
      //       component: () => import('@/views/test/test.vue'),
      //       meta: { title: 'test', icon: 'test' }
      //     }
      //   ]
      // }

      // 新 API 学习: addRoutes, 是 router 身上的方法
      this.$router.addRoutes([
        {
          path: '/test',
          component: Layout,
          children: [
            {
              path: '',
              name: 'test',
              component: () => import('@/views/test/test.vue'),
              meta: { title: 'test', icon: 'test' }
            }
          ]
        }
      ])
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
</style>
